//
//  ViewController.swift
//  learnReadableContentGuides
//
//  Created by NMXY_IOS on 2020/12/28.
//

import UIKit

class ViewController: UIViewController {

    
    /*
     用 ipad 模拟器效果更明显
   */
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.lightGray
        self.view.translatesAutoresizingMaskIntoConstraints = false
        
        self.view.addSubview(self.contentLable)
        
        NSLayoutConstraint.activate([
        
            /* // 通常写的约束
             self.contentLable.leftAnchor.constraint(equalTo: self.view.layoutMarginsGuide.leftAnchor),
             self.contentLable.rightAnchor.constraint(equalTo: self.view.layoutMarginsGuide.rightAnchor),
             self.contentLable.topAnchor.constraint(equalTo: self.view.layoutMarginsGuide.topAnchor)
        */
            
            // 通过 readableContentGuide 写的约束
            self.contentLable.leftAnchor.constraint(equalTo: self.view.readableContentGuide.leftAnchor),
            self.contentLable.rightAnchor.constraint(equalTo: self.view.readableContentGuide.rightAnchor),
            self.contentLable.topAnchor.constraint(equalTo: self.view.layoutMarginsGuide.topAnchor)
            
        ])
        
    }
    
    // content
    private lazy var contentLable: UILabel = {
        let tempLabel = UILabel()
        tempLabel.textColor = UIColor.black
        tempLabel.numberOfLines = 0
        tempLabel.translatesAutoresizingMaskIntoConstraints = false
        tempLabel.backgroundColor = UIColor.white
        tempLabel.text = "This layout guide defines an area that can easily be read without forcing users to move their head to track the lines. The readable content area follows the following rules: 1、The readable content guide never extends beyond the view’s layout margin guide.2、The readable content guide is vertically centered inside the layout margin guide.3、The readable content guide’s width is equal to or less than the readable width defined for the current dynamic text size.Use the readable content guide to lay out a single column of text. If you are laying out multiple columns, you can use the guide’s width to determine the optimal width for your columns."
        return tempLabel
    }()
    


}

